package LeetCode;

//
// Created by ✎﹏ℳ๓独赏☆独醉 on 2024/5/12.
//
//https://leetcode.cn/problems/search-insert-position/submissions/531197965/
public class 搜索插入位置 {
    public static void main(String[] args) {
        int[] nums = {1};
        int target = 4;
        System.out.println(searchInsert(nums,target));
    }
    public static int searchInsert(int[] nums, int target) {
        if(nums.length == 0)return 0;
        int res = -1;
        int left = 0, right = nums.length;
        while(left < right){
            int mid = (left + right) / 2;
            if(nums[mid] >= target)right = mid;
            else left = mid + 1;
        }
        res = left;
        return res;
    }
}
